from django.contrib import admin

from django.conf import settings
if settings.DATABASE_TYPE == 'mysql':
    from tanxi.models.mysql.mysql_user_model import UserModel, UserManager 
    from tanxi.models.mysql.mysql_article_model import ArticleModel
        
elif settings.DATABASE_TYPE == 'sqlite':
    from tanxi.models.sqlite.sqlite_user_model import SqliteUserModel as UserModel
    from tanxi.models.sqlite.sqlite_user_model import SqliteUserManager as UserManager
    from tanxi.models.sqlite.sqlite_article_model import SqliteArticleModel as ArticleModel
else:
    raise ValueError("Unsupported database type specified in settings.")

class CustomArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'author_id', 'publish_time')
    search_fields = ('title', 'content')
    list_filter = ('publish_time',)
    ordering = ('-publish_time',)

admin.site.register(ArticleModel, CustomArticleAdmin)